/**
 * Created by ZFL on 2017/9/21.
 */
var vm=new Vue({
    el:'#lessPay',
    data:{
        orderInfo:[],    //订单信息
        userId:'',      //用户
        orderPayId:''    //订单ID
    }
})
Vue.filter('price',function(value){
    return divideNumber(value,100);
})

function appInit(){
    vm.userId=$.getPara('userId');
    PageInit();
}
function PageInit(){
    lessPay();   //我的优惠买单
}

var pageNum = 1;
var pageSize = 10;
var loading=false;


//滚动加载优惠买单
window.onscroll = function(){
    var scr = $(window).scrollTop();
    var clientH = document.body.clientHeight;
    var scrollH = document.body.scrollHeight;
    if(scr+clientH == scrollH){
        if(loading) return;
        loading = true;
        pageNum++;
        setTimeout(function(){
            lessPay();
        },100)
    }
};

//我的优惠买单
function lessPay(){
    $.ajaxHandler({
        model:function(){
            var obj={};
            obj.userId=$.getPara('userId');
            obj.pageNum = pageNum;
            obj.pageSize = pageSize;
            return obj;
        },
        visibleTime: 0,
        dataType: "json",
        visible:'hide',
        api: 'yg_baijiaapporder/orderPay/selectByPage',
        success:function(result){
            if(result.code===10000){
                var data=result.data;
                if(data.list.length<=0){
                    var height=$(document.body).height();
                    $('.noData').height(height);

                }else{
                    loading = false;
                    data.list.forEach(function(val,ind){
                        vm.orderInfo.push(val)
                    })
                }
            }

        }
    })
}